package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;

class zbbs {
   private Worksheet a;
   private static final com.aspose.cells.b.c.a.za b = new com.aspose.cells.b.c.a.za(new String[]{"color", "font-style", "font-weight", "text-underline-style", "text-line-through", "border-top", "border-right", "border-bottom", "border-left", "border", "background", "mso-background-source", "mso-pattern"});

   zbbs(Worksheet var1) {
      this.a = var1;
   }

   void a(zcfw var1) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         int var2 = this.a.getConditionalFormattings().add();
         FormatConditionCollection var3 = this.a.getConditionalFormattings().get(var2);
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("Range".equals(var1.p())) {
               String var4 = var1.i();
               ArrayList var5 = new ArrayList();
               if (var4 != null && var4.length() > 0) {
                  zbbx.a(var4, var5);
               }

               com.aspose.cells.b.a.a.ze.a(var3.b, (Collection)var5);
            } else if ("Condition".equals(var1.p())) {
               this.a(var1, var3);
            } else {
               var1.a();
            }
         }

         var1.h();
      }
   }

   void a(zcfw var1, FormatConditionCollection var2) throws Exception {
      if (var1.n()) {
         var1.a();
      } else {
         int[] var5 = var2.e();
         int var3 = var5[0];
         int var4 = var5[1];
         String var6 = null;
         String var7 = null;
         String var8 = null;
         String var9 = null;
         var1.d();

         while(var1.r() != 4) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("Qualifier".equals(var1.p())) {
               var6 = var1.i();
            } else if ("Value1".equals(var1.p())) {
               var7 = var1.i();
               var7 = zase.H(var7);
               var7 = zasp.b(var7, var3, var4);
            } else if ("Value2".equals(var1.p())) {
               var8 = var1.i();
               var8 = zase.H(var8);
               var8 = zasp.b(var8, var3, var4);
            } else if ("Format".equals(var1.p())) {
               var9 = var1.a("Style");
               var1.a();
            } else {
               var1.a();
            }
         }

         var1.h();
         int var10 = 6;
         byte var11 = 0;
         if (var6 == null) {
            var11 = 1;
            if (var7 != null && var7.length() > 0 && var7.charAt(0) != '=') {
               var7 = '=' + var7;
            }

            if (var8 != null && var8.length() > 0 && var8.charAt(0) != '=') {
               var8 = '=' + var8;
            }
         } else {
            var10 = zbbx.a(var6);
         }

         int var12 = var2.addCondition(var11, var10, var7, var8);
         if (var9 != null) {
            this.a(var9, var2.get(var12));
         }

      }
   }

   private void a(String var1, FormatCondition var2) {
      Style var3 = var2.getStyle();
      String[] var4 = com.aspose.cells.b.a.zv.d(var1, ';');

      for(int var5 = 0; var5 < var4.length; ++var5) {
         String var6 = var4[var5].trim();
         if (var6.length() != 0) {
            String[] var7 = com.aspose.cells.b.a.zv.d(var6, ':');
            if (var7.length >= 1) {
               String var8 = var7[0].trim();
               String var9 = var7[1].trim();
               if (var8.length() != 0 && var9.length() != 0) {
                  this.a(var3, var8, var9);
               }
            }
         }
      }

   }

   private Color a(String var1) {
      Color var2 = Color.getEmpty();

      try {
         if (var1.startsWith("#")) {
            var2 = zbbx.c(var1.substring(1));
         } else {
            var2 = Color.a(var1);
            if (var2.getA() == 0 && var2.getR() == 0 && var2.getG() == 0 && var2.getB() == 0 && !"black".equals(var1.toLowerCase())) {
               var2 = Color.getEmpty();
            }
         }
      } catch (Exception var4) {
         ;
      }

      return var2;
   }

   private void a(Style var1, String var2, String var3) {
      switch(b.a(var2)) {
      case 0:
         if ("windowtext".equals(var3)) {
            var1.getFont().b.a(true);
            var1.b(16);
         } else {
            Color var4 = this.a(var3);
            if (!com.aspose.cells.a.c.zh.a(var4)) {
               var1.getFont().setColor(var4);
            }
         }
         break;
      case 1:
         if ("italic".equals(var3)) {
            var1.getFont().setItalic(true);
         }
         break;
      case 2:
         var1.getFont().b(com.aspose.cells.b.a.zo.a(var3));
         break;
      case 3:
         var1.getFont().setUnderline(zbbx.b(var3));
         break;
      case 4:
         if ("none".equals(var3)) {
            var1.getFont().setStrikeout(false);
         } else {
            var1.getFont().setStrikeout(true);
         }
         break;
      case 5:
         this.a(var1, 4, var3);
         break;
      case 6:
         this.a(var1, 2, var3);
         break;
      case 7:
         this.a(var1, 8, var3);
         break;
      case 8:
         this.a(var1, 1, var3);
         break;
      case 9:
         this.a(var1, 4, var3);
         this.a(var1, 2, var3);
         this.a(var1, 8, var3);
         this.a(var1, 1, var3);
         break;
      case 10:
         this.b(var1, var3);
         break;
      case 11:
         this.b(var1, var3);
         break;
      case 12:
         this.a(var1, var3);
      }

   }

   private void a(Style var1, String var2) {
      String var3 = null;
      String var4 = null;
      String[] var5 = com.aspose.cells.b.a.zv.d(var2, ' ');
      if (var5.length == 2) {
         var3 = var5[0];
         var4 = var5[1];
      } else {
         var3 = var5[0];
         var4 = var5[0];
      }

      if ("auto".equals(var3)) {
         var1.b.a(true);
         var1.b(34);
      } else {
         Color var6 = this.a(var3);
         if (!com.aspose.cells.a.c.zh.a(var6)) {
            var1.setForegroundColor(var6);
         }
      }

      int var7 = zbbx.e(var4);
      if (var7 != 0) {
         var1.setPattern(var7);
      }

   }

   private void b(Style var1, String var2) {
      if ("auto".equals(var2)) {
         var1.a.a(true);
         var1.b(35);
      } else {
         Color var3 = this.a(var2);
         if (!com.aspose.cells.a.c.zh.a(var3)) {
            var1.setBackgroundColor(var3);
         }
      }

   }

   private void a(Style var1, int var2, String var3) {
      Border var4 = var1.getBorders().getByBorderType(var2);
      if ("none".equals(var3)) {
         var4.setLineStyle(0);
      } else {
         String[] var5 = com.aspose.cells.b.a.zv.d(var3, ' ');
         if (var5.length == 3) {
            try {
               var4.setLineStyle(zbbx.d(var5[0] + " " + var5[1]));
            } catch (Exception var8) {
               ;
            }

            String var6 = var5[2];
            if ("windowtext".equals(var6)) {
               var4.a.a(true);
            } else {
               Color var7 = this.a(var6);
               if (!com.aspose.cells.a.c.zh.a(var7)) {
                  var4.setColor(var7);
               }
            }

         }
      }
   }
}
